package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import com.zzyl.vo.NursingProjectPojo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description NursingPlanController
 * @Author huangdongye
 * @Date 2025-05-08  16:31
 */
@RequestMapping("/nursing/plan")
@RestController
@Api(tags = "护理计划管理")
public class NursingPlanController extends BaseController {
    @Autowired
    private NursingPlanService nursingPlanservice;

    @GetMapping
    public ResponseResult<List<NursingPlanVo>> allNursingPlan() {
        List<NursingPlanVo> result = nursingPlanservice.allNursingPlan();
        return success(result);
    }


    @PostMapping
    public ResponseResult addNursingPlan(@RequestBody NursingPlanVo npv) {
        nursingPlanservice.addNursingPlan(npv);
        return success();
    }


    @GetMapping("/search")
    public ResponseResult<PageResponse<NursingPlanVo>> PageNursingPlan(NursingProjectPojo NursingPlan) {
        PageResponse<NursingPlanVo> result = nursingPlanservice.PageNursingPlan(NursingPlan);
        return success(result);
    }


    @GetMapping("/{id}")
    @ApiOperation("根据id查询")
    public ResponseResult<NursingPlanVo> NursingPlanById(@PathVariable("id") Long id) {
        NursingPlanVo result = nursingPlanservice.NursingPlanById(id);
        return success(result);
    }

    @PutMapping("/{id}")
    @ApiOperation("根据id修改")
    public ResponseResult updateNursingPlanById(@RequestBody NursingPlanVo NursingPlan) {
        nursingPlanservice.updateNursingPlanById(NursingPlan);
        return success();
    }

    @DeleteMapping("/{id}")
    @ApiOperation("根据id删除")
    public ResponseResult deleteNursingPlanById(@PathVariable("id") Long id) {
        nursingPlanservice.deleteNursingPlan(id);
        return success();
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation("修改开关状态")
    public ResponseResult updateSwitch(@PathVariable Long id, @PathVariable Integer status){
        nursingPlanservice.updateSwitch(id,status);
        return success();
    }
}
